package com.wxf.book1_38;

import java.util.Scanner;

public class FDiGui {

	public static void main(String[] args) {
		System.out.println("请输入要求的第几项：");
		Scanner sc = new Scanner(System.in);
		long result1 = sc.nextLong();		
		System.out.println(fFDiGui(result1));
	}
	
	static long fFDiGui(long n) {
		long p1 = 1;
		long p2 = 1;

		if (n == 1 || n == 2) {
			p2 = 1;
		}else {
		  // 从第三项开始，是前两项之和
			for (int i = 1; i <= n - 2; i++) {	
				p2 = p1 + p2 ;   // 计算后一项是前两项之和
				p1 = p2 - p1;    // 把旧的param2的值赋值给param1
			}
		}
		return p2;
	}

}
